package com.honglv.controller.common;

import com.honglv.exception.BaseException;
import com.honglv.pojo.dto.LikeDTO;
import com.honglv.pojo.result.Result;
import com.honglv.pojo.vo.LikeVO;
import com.honglv.service.LikeService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@Api("点赞接口")
public class LikeController {

    @Autowired
    private LikeService likeService;

    @GetMapping("/like")
    public Result<LikeVO> like(LikeDTO likeDTO){
        if(likeDTO == null || likeDTO.getStatus() == null || likeDTO.getId() == null){
            throw new BaseException("参数为空");
        }
        LikeVO likeVO = likeService.like(likeDTO);
        if (likeVO == null){
            return Result.success("无该文章数据");
        }
        return Result.success(likeVO);
    }
}
